//
//  BaseTableViewController.swift
//  sinaweibo
//
//  Created by mac on 15/11/9.
//  Copyright © 2015年 mac. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController, VisitorLoginViewDelegate {

    //添加用户是否登录标记
    var userLogin = UserAccountViewModel().userLogin
//    var userLogin = false
    var visitorLoginView: VisitorLoginView?
    
    override func loadView() {
        
//        loadVisitorView()
        userLogin ? super.loadView() : loadVisitorView()
    }
    
    private func loadVisitorView() {
        
        visitorLoginView = VisitorLoginView()
        visitorLoginView?.visitorDelegate = self
        
        view = visitorLoginView

        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登陆", style: .Plain, target: self, action: "visitorWillLogin")
        self.navigationItem.rightBarButtonItem =  UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "visitorWillRegister")
    }
    
    func visitorWillLogin() {
    
        print("登陆")
        let oauth = OAuthViewController()
        let nav = UINavigationController(rootViewController: oauth)
        presentViewController(nav, animated: true, completion: nil)
    }
    
    func visitorWillRegister() {
    
        print("注册")
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

     
    }
}
